package com.kaussoft.lolblog.vo;

import java.io.Serializable;
import java.util.Set;

/** 
 * 		@hibernate.class
 * 		 table="WBLOG"
 */
public class Wblog implements Serializable {

	// serialVersionUID
	private static final long serialVersionUID = 1L;
	
	// hashCode
	private int hashCode = Integer.MIN_VALUE;

	// primary key
	private Integer wblogid;
	
	// fields
	private String wblogdesc;
	private String wblogname;
	
	// many to one
	private Account createBy;
	
	// collections
	private Set<Part> parts;
	private Set<Article> articles;
	
	/** default constructor */
	public Wblog() {
		
	}

	/** primary key constructor */
	public Wblog(Integer wblogid) {
		this.setWblogid(wblogid);
	}
	
	/** required fields constructor */
	public Wblog(Integer wblogid, String wblogname, String wblogdesc) {
		this.setWblogid(wblogid);
		this.setWblogname(wblogname);
		this.setWblogdesc(wblogdesc);
	}

	/**
	 * 		@hibernate.set
	 * 		 lazy="true"
     *       inverse="true"
     *       cascade="all-delete-orphan"
     *      @hibernate.key
     *       column="WBLOG_ID"
     *      @hibernate.one-to-many
     *       class="com.kaussoft.lolblog.vo.Part"
	 */
	public Set<Part> getParts() {
		return parts;
	}

	public void setParts(Set<Part> parts) {
		this.parts = parts;
	}

	/**
	 * 		@hibernate.property
	 * 		 column="WBLOG_DESC"
	 */
	public String getWblogdesc() {
		return wblogdesc;
	}

	public void setWblogdesc(String wblogdesc) {
		this.wblogdesc = wblogdesc;
	}

	/**
	 * 		@hibernate.id
	 * 		 column="WBLOG_ID"
	 * 		 generator-class="native"
	 * 		 type="java.lang.Integer"
	 * 		 unsaved-value=null
	 * 		@hibernate.generator-param name="sequence" value="SQ_WBLOG_ID"
	 */
	public Integer getWblogid() {
		return wblogid;
	}

	public void setWblogid(Integer wblogid) {
		this.wblogid = wblogid;
		this.hashCode = Integer.MIN_VALUE;
	}

	/**
	 * 		@hibernate.property
	 * 		 column="WBLOG_NAME"
	 */
	public String getWblogname() {
		return wblogname;
	}

	public void setWblogname(String wblogname) {
		this.wblogname = wblogname;
	}
	
	/**
	 * 		@hibernate.set
	 * 		 lazy="true"
     *       inverse="true"
     *       cascade="all-delete-orphan"
     *      @hibernate.key
     *       column="WBLOG_ID"
     *      @hibernate.one-to-many
     *       class="com.kaussoft.lolblog.vo.Article"
	 */
	public Set<Article> getArticles() {
		return articles;
	}

	public void setArticles(Set<Article> articles) {
		this.articles = articles;
	}
	
	/**
	 *		@hibernate.many-to-one
	 *		 column="ACCOUNT_ID"
	 *		 class="com.kaussoft.lolblog.vo.Account"
	 *		 not-null="true"
	 */
	public Account getCreateBy() {
		return createBy;
	}

	public void setCreateBy(Account createBy) {
		this.createBy = createBy;
	}
	
	public boolean addToParts(Object obj) {
		if (null == obj)
			return false;
		if (!(obj instanceof Part)) 
			return false;
		else {
			Part aObj = (Part)obj;
			if (null == this.parts) 
				this.parts = new java.util.HashSet<Part>();
			return this.parts.add(aObj);
		}
	}
	
	public boolean addToArticles(Object obj) {
		if (null == obj)
			return false;
		if (!(obj instanceof Article)) 
			return false;
		else {
			Article aObj = (Article)obj;
			if (null == this.articles) 
				this.articles = new java.util.HashSet<Article>();
			return this.articles.add(aObj);
		}
	}

	public boolean equals(Object obj) {
		if (null == obj) 
			return false;
		if (!(obj instanceof Wblog)) 
			return false;
		else {
			Wblog aObj = (Wblog) obj;
			if (null == this.getWblogid() || null == aObj.getWblogid()) 
				return false;
			else 
				return (this.getWblogid().equals(aObj.getWblogid()));
		}
	}
	
	public int hashCode() {
		if (Integer.MIN_VALUE == this.hashCode) {
			if (null == this.getWblogid()) 
				return super.hashCode();
			else {
				String hashStr = this.getClass().getName() + ":" + this.getWblogid().hashCode();
				this.hashCode = hashStr.hashCode();
			}
		}
		return this.hashCode;
	}

	public String toString() {
		return super.toString();
	}
}
